/* 
 * File:   CheckerTexture.cpp
 * Author: neuma173
 * 
 * Created on October 3, 2011, 11:59 AM
 */

#include <textures/CheckerTexture.h>

CheckerTexture::CheckerTexture(const Vector3D& color1, const Vector3D& color2, double checksize) {
    this->color1 = color1;
    this->color2 = color2;
    this->checkSize = checksize; //precompute inverse?
}

CheckerTexture::CheckerTexture(const CheckerTexture& orig) {
}

CheckerTexture::~CheckerTexture() {
}

Vector3D CheckerTexture::getColor(const IntersectionResult& ir){
    Vector3D p = ir.hitPoint * (1.0/checkSize);
    int val = (clamp(p[0]) + clamp(p[1]) + clamp(p[2]))%2;
    if(val == 0){
        return color1;
    }
    else return color2;
}

Vector3D CheckerTexture::getNormal(const IntersectionResult& ir){
    return ir.normal;
}